package regulator;
import java.util.*;
import java.io.*;

 class Mai {

    public static void main(String[] args) throws IOException {
        // Scanner
//        Scanner in = new Scanner(System.in);
//        int n = in.nextInt(), m = in.nextInt();
//        int[][] nums = new int[n][m];
//        for ( int i = 0; i < n; i++ ) {
//            for ( int j = 0; j < m; j++ ) {
//                nums[i][j] = in.nextInt();
//            }
//        }

        // BufferedReader
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int n = Integer.parseInt(line[0]), m = Integer.parseInt(line[1]);
        int[][] nums = new int[n][m];
        for ( int i = 0; i < n; i++ ) {
            line = br.readLine().split(" ");
            for ( int j = 0; j < m; j++ ) {
                nums[i][j] = Integer.parseInt(line[j]);
            }
        }

        // StreamTokenizer
//        Input in = new Input();
//        int n = in.nextInt(), m = in.nextInt();
//        int[][] nums = new int[n][m];
//        for ( int i = 0; i < n; i++ ) {
//            for ( int j = 0; j < m; j++ ) {
//                nums[i][j] = in.nextInt();
//            }
//        }

        // 输出数组
//        for ( int i = 0; i < n; i++ ) {
//            for ( int j = 0; j < m; j++ ) {
//                System.out.print(nums[i][j] + " ");
//            }
//            System.out.println();
//        }
    }

}
class Input {
    StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    public int nextInt() throws IOException {
        in.nextToken();
        return (int)in.nval;
    }
}


 class main {

    public static void main(String[] args) throws IOException {
        // 优化输入
        Input in = new Input();
        int n = in.nextInt(), m = in.nextInt();
        int[][] nums = new int[n][m];
        for ( int i = 0; i < n; i++ ) {
            for ( int j = 0; j < m; j++ ) {
                nums[i][j] = in.nextInt();
            }
        }

        // 直接输出
//        for ( int i = m-1; i >= 0; i-- ) {
//            for ( int j = 0; j < n; j++ ) {
//                System.out.print(nums[j][i]+" ");
//            }
//            System.out.println();
//        }

        // StringBuilder缓冲输出
//        StringBuilder sb = new StringBuilder();
//        for ( int i = m-1; i >= 0; i-- ) {
//            for ( int j = 0; j < n; j++ ) {
//                sb.append(nums[j][i]+" ");
//            }
//            sb.append("\n");
//        }
//        System.out.println(sb.toString());

        // PrintWriter输出
//        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
//
//        for ( int i = m - 1; i >= 0; i-- ) {
//            for ( int j = 0; j < n; j++ ) {
//                out.print(nums[j][i] + " ");
//            }
//            out.println();
//        }
//        out.flush();
    }

}
class InputQuick {
    StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    public int nextInt() throws IOException {
        in.nextToken();
        return (int)in.nval;
    }
}
